package com.probox.apiModules.controller.platfom;

import com.probox.common.core.enums.DataStatus;
import com.probox.common.core.utils.SecurityUtils;
import com.probox.common.core.web.controller.BaseController;
import com.probox.common.core.web.domain.AjaxResult;
import com.probox.common.entity.domain.platfom.PlatformCms;
import com.probox.common.entity.domain.platfom.vo.PlatformCmsVo;
import com.probox.common.entity.domain.platfom.vo.PlatformCnsQuery;
import com.probox.common.entity.service.platfom.IPlatformCmsClassService;
import com.probox.common.entity.service.platfom.IPlatformCmsService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiResponse;
import io.swagger.annotations.ApiResponses;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
 * (资讯/平台/公告)信息Controller
 *
 *
 * @date 2021-06-11
 */
@Api(value = "平台设置模块", tags = {"(资讯/平台/公告)信息前端接口"})
@RestController
@RequestMapping("/platform")
public class OPenPlatformCmsController extends BaseController {

    @Autowired
    private IPlatformCmsService platformCmsService;

    @Autowired
    private IPlatformCmsClassService platformCmsClassService;


    /**
     * 查询(资讯/平台/公告)信息列表
     */
    @GetMapping("/cmsApi/listAboutUsCategory")
    @ApiOperation(value = "关于我们列表")
    public AjaxResult listAboutUsCategory() {
        return AjaxResult.success(platformCmsClassService.queryCategoryList());
    }

    /**
     * 查询(资讯/平台/公告)信息列表
     */
    @GetMapping("/cmsApi/list")
    @ApiOperation(value = " 查询(资讯/平台/公告)信息列表")
    @ApiResponses({
            @ApiResponse(code = 200,message = "OK",response = PlatformCms.class),
    })
    public AjaxResult list(PlatformCms platformCms) {
        platformCms.setDataStatus(DataStatus.valid.getKey());
        platformCms.setPlatformUid(SecurityUtils.getCustomerPlatformUid());
        startPage();
        List<PlatformCmsVo> list = platformCmsService.queryList(platformCms);
        return AjaxResult.successs(list, platformCmsService.queryListCount(platformCms));
    }

    /**
     * 查询(资讯/平台/公告)信息
     */
    @GetMapping("/cmsApi/get")
    @ApiOperation(value = " 查询(资讯/平台/公告)信息")
    @ApiResponses({
            @ApiResponse(code = 200,message = "OK",response = PlatformCms.class),
    })
    public AjaxResult get(PlatformCnsQuery query) {
        query.setPlatformUid(SecurityUtils.getCustomerPlatformUid());
        return AjaxResult.success(platformCmsService.get(query));
    }


}
